import 'package:cbec_app/entity/home/content/content_data.dart';

class VideoModel extends ContentData {
  String? uuid;
  String? selectUrl;
  int? videoChamfer;
  int? pagePadding;
  int? surfacePlot;
  int? progressBar;
  int? voicePosition;
  int? autoPlay;
  bool? muted;
  int? sourceFrom;
  String? customUrl;
  String? surfacePlotImage;

  VideoModel({
    this.uuid,
    this.selectUrl,
    this.videoChamfer,
    this.pagePadding,
    this.surfacePlot,
    this.progressBar,
    this.voicePosition,
    this.autoPlay,
    this.muted,
    this.sourceFrom,
    this.customUrl,
    this.surfacePlotImage,
  }) {
    type = 'video'; // 设置 type 属性
  }

  // 从 JSON 创建实例
  factory VideoModel.fromJson(Map<String, dynamic> json) {
    return VideoModel(
      uuid: json['uuid'] ?? '',
      selectUrl: json['selectUrl'] ?? '',
      videoChamfer: json['videoChamfer'] ?? 1,
      pagePadding: json['pagePadding'] ?? 0,
      surfacePlot: json['surfacePlot'] ?? 1,
      progressBar: json['progressBar'] ?? 1,
      voicePosition: json['voicePosition'] ?? 2,
      autoPlay: json['autoPlay'] ?? 1,
      muted: json['muted'] ?? true,
      sourceFrom: json['sourceFrom'] ?? 1,
      customUrl: json['customUrl'] ?? '',
      surfacePlotImage: json['surfacePlotImage'] ?? '',
    );
  }

  @override
  ContentData fromJson(Map<String, dynamic> json) {
    return VideoModel.fromJson(json);
  }

  // 转换为 JSON
  @override
  Map<String, dynamic> toJson() {
    return {
      'uuid': uuid,
      'selectUrl': selectUrl,
      'videoChamfer': videoChamfer,
      'pagePadding': pagePadding,
      'surfacePlot': surfacePlot,
      'progressBar': progressBar,
      'voicePosition': voicePosition,
      'autoPlay': autoPlay,
      'muted': muted,
      'sourceFrom': sourceFrom,
      'customUrl': customUrl,
      'surfacePlotImage': surfacePlotImage,
      'type': type,
    };
  }
}
